package com.lm.common.log;

import com.lm.common.log.aspect.SysOperLogAspect;
import com.lm.common.log.listener.LogListener;
import com.lm.upms.api.feign.RemoteLogService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableAsync;

/**
 * 日志启动类
 *
 * @author lm
 * @date 2019/7/9 10:06
 */
@Slf4j
@EnableAsync
@Configuration
@AllArgsConstructor
@ConditionalOnWebApplication
public class LogAutoConfiguration {

    @Autowired
    private RemoteLogService logService;

    @Bean
    public LogListener sysOperLogListener() {
        log.info("start LogListener~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
        return new LogListener(logService);
    }

    @Bean
    public SysOperLogAspect operLogAspect() {
        log.info("start SysOperLogAspect~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
        return new SysOperLogAspect();
    }

}